package com.lighting.smssystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lighting.smssystem.model.Company;
import com.lighting.smssystem.model.bo.CompanyList;
import com.lighting.smssystem.model.vo.CompanyFilterNew;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author leemaster
 * @Title: CompanyMapper
 * @Package com.lighting.smssystem.mapper
 * @Description:
 * @date 2019-06-0123:56
 */
@Mapper
public interface CompanyMapper extends BaseMapper<Company> {

    @Select("select " +
            "   c.company_id as company_id," +
            "   c.company_name as company_name," +
            "   c.company_legal as company_legal," +
            "   c.company_province as company_province," +
            "   c.company_city as company_city," +
            "   c.company_type as company_type," +
            "   c.company_tel as company_tel," +
            "   c.company_other_tel as company_other_tel," +
            "   c.company_address as company_address," +
            "   c.company_website as company_website," +
            "   c.company_mail as company_mail," +
            "   c.company_range as company_range," +
            "   c.update_at as update_at," +
            "   c.create_at as create_at" +
            "from company_tbl as c, user_favorite_tbl as u" +
            "<where>" +
            "   c.company_id = u.favorite_company" +
            "   and u.favorite_user = #{id}(" +
            "   <if test=\"filter.cityKey != null \">and c.company_province like #{id}</if>" +
            "   <if test=\"filter.cityKey != null \">and c.company_city like #{id}</if>" +
            "   <if test=\"filter.cityKey != null \">and id like #{id}</if>" +
            "   <if test=\"filter.cityKey != null \">and id like #{id}</if>" +
            "   )" +
            "</where>"
    )
    List<Company> listUserFavorite(@Param("id") Long userId,@Param("filter") CompanyFilterNew filter);
}
